Azure Firewall/Script - Migrate Palo Alto config to Azure Firewall Policy/pa2azfw.py (633 lines of code) (raw):
��i m p o r t a r g p a r s e
i m p o r t j s o n
i m p o r t r e
i m p o r t o s
i m p o r t s y s
i m p o r t c o p y
# h t t p s : / / d o c s . p y t h o n . o r g / 3 / l i b r a r y / i p a d d r e s s . h t m l
i m p o r t i p a d d r e s s
# H e l p e r f u n c t i o n s
# T r u e i f a n y o f t h e u r l s c o n t a i n e d i n t h e U R L l i s t c o n t a i n s a w i l d c a r d ( ' * ' )
d e f u r l s _ c o n t a i n _ w i l d c a r d ( u r l s ) :
f o r u r l i n u r l s :
i f ' * ' i n u r l :
r e t u r n T r u e
r e t u r n F a l s e
# C h e c k w h e t h e r U R L s a r e c o r r e c t :
# - W i l d c a r d n e e d s t o b e i n t h e b e g i n n i n g o f t h e s t r i n g , n o t v a l i d i n t h e m i d d l e
d e f v e r i f y _ u r l s ( u r l s ) :
c o r r e c t e d _ u r l s = [ ]
f o r u r l i n u r l s :
i f u r l . f i n d ( ' * ' ) <